import { uniqueId } from 'lodash-unified'
import type { CsSelectProps } from 'csui'
type UseCsSelectProps<
  D extends Record<string, any>,
  P extends keyof Readonly<D>
> = UseFormItemProps<CsSelectProps, D, P>

/**
 * cs-title
 * @param label item.label
 * @param props item的其他属性
 * @returns form-item-data
 */
export function useTitle<
  T extends Record<string, any>,
  P extends keyof T
>(label: string, props: UseCsSelectProps<T, P> = {}): FormItemProps<T, P> {
  return {
    label: '',
    prop: uniqueId(),
    component: 'cs-title',
    props: {
      title: label
    },
    class: 'cs-form-item__title',
    span: 24,
    ...props
  }
}
